package com.wellink.android_demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.wellink.android_demo.com.wellink.android_demo.listener.BtnClickListener;

public class DemoActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.demo1_layout);

        Button btn1 = findViewById(R.id.btn1);

        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(DemoActivity.this,"收到匿名内部类点击事件",Toast.LENGTH_SHORT).show();
            }
        });

        Button btn2 = findViewById(R.id.btn2);
        btn2.setOnClickListener(new InnerBtnClickListener());

        Button btn3 = findViewById(R.id.btn3);
        btn3.setOnClickListener(new BtnClickListener(this));

    }

    class InnerBtnClickListener implements View.OnClickListener{

        @Override
        public void onClick(View v){
            Toast.makeText(DemoActivity.this,"收到内部类的点击事件",Toast.LENGTH_SHORT).show();
        }
    }

    public void clickHandler(View source){
        Toast.makeText(DemoActivity.this,"收到绑定标签的点击事件",Toast.LENGTH_SHORT).show();
    }

}
